package com.ecloud.service.translate.config;

import java.time.Duration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.ecloud.common.cache.cache.CustomizedCacheConfig;
import com.ecloud.common.cache.cache.IRedisCaffeineCacheConfig;
import com.ecloud.common.cache.cache.RedisCaffeineConfig;

/**
 * 自定义缓存配置
 *
 * @author LiuGangQiang Create in 2021/09/10
 */
@Configuration
public class CacheConfiguration {

    /**
     * 自定义缓存配置
     *
     * @author LiuGangQiang Create in 2021/09/10
     * @return {@link IRedisCaffeineCacheConfig}
     */
    @Bean
    public IRedisCaffeineCacheConfig redisCaffeineCacheConfig() {
        CustomizedCacheConfig init = new CustomizedCacheConfig();
        init.set("dict", RedisCaffeineConfig.defaultCacheConfig().setExpire(Duration.ofMinutes(1)));
        init.set("translate", RedisCaffeineConfig.defaultCacheConfig().setExpire(Duration.ofMinutes(1)));
        return init;
    }
}
